const Utils = require("./utils.js")
const {CN,EN} = require("./constant.js")

module.exports = class Notebook{
	constructor($env,$event){
		this.$event = $event;

		this.$dom = Utils.createDOM("div",{
			id: "draw-note-book",
			class:`draw-note-book base-mask ${CN.slide_hide}`
		})
		this.__tpl = `<textarea class="input-note-book input-box-input">`;
		this.$dom.innerHTML = this.__tpl;
		this.input = this.$dom.querySelector(".input-box-input")

		$event.emit(EN.append,this.$dom)
		
		this.bind()
	}
	bind(){
		this.input.addEventListener("click",(e)=>{
			e.stopPropagation()
			e.preventDefault()
		})
		this.$dom.addEventListener("click",(e)=>{
			this.toggle(this.$dom.classList.contains(CN.slide_hide))
		})
	}
	toggle(isShow){
		this.$dom.classList[isShow?"remove":"add"](CN.slide_hide);
	}
}